package car.aistar.controller;

import car.aistar.bo.LaoxuUpdate;
import car.aistar.dto.Result;
import car.aistar.entity.UserDetail;
import car.aistar.service.UserDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
*@Author laoxu
*@Description //TODO 个人中心用户信息修改
*@Date 7:19 2020/10/7
*@Param
*@return
**/
@RestController
@RequestMapping("userDetail")
public class UserDetailController {
    /**
     * 服务对象
     */
    @Autowired
    private UserDetailService userDetailService;


    @PostMapping("update")
    public @ResponseBody Result updateDetail(LaoxuUpdate laoxuUpdate){
        //初始化详情实体类对象
        UserDetail userDetail = new UserDetail();
        //用户id
        String uid = "4";
        userDetail.setUId(Integer.valueOf(uid));
        userDetail.setId(Long.valueOf(uid));
        userDetail.setUname(laoxuUpdate.getUname());
        userDetail.setUpwd(laoxuUpdate.getUpwd());
        userDetail.setUphoto(laoxuUpdate.getUphoto());
        UserDetail userDetail1 = userDetailService.update(userDetail);
        return new Result("200","修改成功",userDetail1);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public UserDetail selectOne(Long id) {
        return this.userDetailService.queryById(id);
    }

}